import 'package:flutter/material.dart';
import './main.dart';
import './record.dart';

final Map routes = {
  "/": (context) => const HomePage(),
  "/record": (context) => const GameRecordPage(),
};

var Fun = (RouteSettings settings) {
  // print(settings);
  // print(settings.name);
  // print(settings.arguments);

  final String? name = settings.name; //  /news 或者 /search
  final Function? pageContentBuilder =
      routes[name]; //  Function = (contxt) { return const NewsPage()}

  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));

      return route;
    }
  }
  return null;
};
